
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
	<title>用户登录</title>

    <link rel="shortcut icon" th:href="@{/images/favicon.ico}"/>
    <link rel="stylesheet" th:href="@{/css/css_x/login/member-base.css}" />
    <link rel="stylesheet" th:href="@{/css/css_x/login/loginss.css}" />

	<script th:src="@{/js/contactus/jquery-3.2.1.js}"></script>
	<script th:src="@{/js/js_x/login/login.js}"></script>
	<script th:inline="javascript">
		/*<![CDATA[*/
		var contextPath = [[${#request.getContextPath()}]]; //获取当前应用路径
		/*]]>*/
	</script>
</head>
<body>
<!--头部-->
<!--<div></div>-->
<div class="login-header">
	<div class="w-1190">
		<div class="login-header">
			<em class="logo pull-left">
				<img th:src="@{/images/img_x/download.png}" style="margin-top: -20px;"/>
				<span class="title col-9">欢迎登录</span>
			</em>
		</div>
	</div>
</div>

<!--登录-->
<div class="login-content">
	<div class="login-content-body">
		<div class="login-add"></div>
		<div class="login-box-warp">
			<div class="box">
				<div class="title font16">
					<i class="spacer-l"></i>
					<h3 class="bold">用户登录</h3>
					<i class="spacer-r"></i>
				</div>
		        <!--注  册-->
		        <div class="login-body">
		            <form  id="form" th:action="@{/f/t/fLogin}" method="post">
						<label id="sc">
						</label>
		                <div class="field username-field text-d">

		                    <label>登录帐号</label>
		                    <input class="text" name="phoneNumber" id="userName" type="text" placeholder="手机号码" value="">
		                </div>
		                <div class="field username-field text-d">
		                    <label>登录密码</label>
		                    <input class="text" name="password" id="password" type="password"  placeholder="密码" value=""  style="color:#999">
		                </div> 

		                <!--提示-->
		                <div class="prompt col-f4 field"><span id="error_pwd" style="display:none;"><i></i>请输入正确的密码</span></div>
		                <div class="remember">
		                    <span class="pull-left"><label><input name="checkboxsave" type="checkbox" value="checked" checked="checked">记住登录帐号</label></span>
		                     <span>忘记密码？<a th:href="@{/f/t/finpo}" class="orange">找回密码&gt;</a></span>
		                </div>
		                <button class="login-but cur" type="button" id="btn_login" th:onclick="|login()|">立即登录</button>
		                        
		                <div class="no-user center">
	                        <span>还没有账号？<a th:href="@{/f/t/register}" class="orange">去注册&gt;</a></span>
	                    </div>      
		            </form>
		        </div>
			</div>
       	</div>
	</div>
</div>

<div class="login-copyright">
	<!--底部版权-->
	<div class="foot">
		<div class="foot-body w-1190">
			<p class="copyright">&copy;2019 有限公司  ALL RIGHTS RESERVED. <span class="tel">7*24h服务热线：</span></p>
			<em class="nav-line center col-9"><a target="_blank" th:href="@{/f/t/showmain}">官网</a>|<a target="_blank" th:href="@{/f/t/about}">关于我们</a>|<a target="_blank" th:href="@{/f/t/contactus}">联系我们</a></em>
		</div>
	</div>
</div>
</body>
<script type="text/javascript">

		/*$(function () {
			if ($("#judge").val() == 2) {
				$("#sc").append("<div style='color: red ;text-align: center' ><i></i><span>用户不存在!</span></div>");
			} else if ($("#judge").val() == 1) {
				$("#sc").append("<div style='color: red ;text-align: center'><i ></i><span>用户名/密码错误!</span></div>");
			}else if($("#judge").val() == 3){
				layer.msg("密码修改成功请重新登陆")
			}
		});*/

		 function login() {
			 if(validate()){
				 $.ajax({
					 url: contextPath + "/f/t/fLogin",
					 data: {"phoneNumber":$("#userName").val(),"password":$("#password").val()},
					 method: "post",
					 success: function (data) {
						 if (data == 1) {
						     //登录成功后返回上一次访问的路径
                             window.location.href = document.referrer;
						 } else if (data == 2) {
							 $("#sc").append("<div style='color: red ;text-align: center'><i ></i><span>账号已锁定!</span></div>");
						 }else if(data == 3){
							 $("#sc").append("<div style='color: red ;text-align: center'><i ></i><span>账号或密码错误!</span></div>");
						 }
					 }
				 });
			 }
		 }

		/**
		 * 提交前验证
		 * @returns {boolean}
		 */
		function validate() {
			 $("#sc").html('');

			 var phoneNumber = $('form').find('input#userName').val();
			 var password = $(this).find('input#password').val();

			 var reg = /^(1[34578]\d{9})$/; //校验手机号
			 if(phoneNumber == '') {
				 $("#sc").append("<div style='color: red ;text-align: center'><i ></i><span>手机号不能为空!</span></div>");
				 return false;
			 }else if (!reg.test(phoneNumber)){
				 $("#sc").append("<div style='color: red ;text-align: center'><i></i><span>请输入正确的手机号!</span></div>");
				 return false;
			 }
			 if(password == '') {
				 $("#sc").append("<div style='color: red ;text-align: center'><i></i><span>密码不能为空!</span></div>");
				 return false;
			 }
			 return true;
		 }

</script>

</html>

